import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/login'),
    meta: {
      title: '登录'
    }
  }, {
    path: '/reg',
    name: 'reg',
    component: () => import('../views/reg/reg'),
    meta: {
      title: '登录'
    }
  }, {
    path: '/index',
    name: 'index',
    redirect: '/home',
    component: () => import('../views/index'),
    meta: {
      title: '首页'
    },
    children: [{
      path: '/home',
      name: 'home',
      component: () => import('../views/home/home'),
      meta: {
        title: '首页'
      },
    }, {
      path: '/order',
      name: 'order',
      component: () => import('../views/order/order'),
      meta: {
        title: '订单'
      },
    }, {
      path: '/order_details',
      name: 'order_details',
      component: () => import('../views/order/order_details'),
      meta: {
        title: '订单详情'
      },
    }, {
      path: '/menu',
      name: 'menu',
      component: () => import('../views/menu/menu'),
      meta: {
        title: '商品列表'
      },
    }, {
      path: '/menuType',
      name: 'menuType',
      component: () => import('../views/menu/menuType'),
      meta: {
        title: '商品分类'
      },
    }, {
      path: '/user',
      name: 'user',
      component: () => import('../views/user/user'),
      meta: {
        title: '用户列表'
      },
    }, {
      path: '/admin',
      name: 'admin',
      component: () => import('../views/user/admin'),
      meta: {
        title: '管理员列表'
      },
    }, {
      path: '/carousel',
      name: 'carousel',
      component: () => import('../views/other/carousel'),
      meta: {
        title: '轮播图列表'
      },
    }, {
      path: '/capital',
      name: 'capital',
      component: () => import('../views/finance/capital'),
      meta: {
        title: '资金流水'
      },
    }, {
      path: '/recharge',
      name: 'recharge',
      component: () => import('../views/finance/recharge'),
      meta: {
        title: '充值管理'
      },
    }, {
      path: '/personal',
      name: 'personal',
      component: () => import('../views/personal/personal'),
      meta: {
        title: '个人中心'
      },
    }]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
